package com.example.springboot.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.*;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.util.Date;


//@Getter
//@Setter
@Data
public class DbBackup {

    private Integer id;

    private String name;

    private String path;

    private Integer type;

    private String operator;

    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableLogic
    private Integer deleted;

    private Integer state;

     public DbBackup() {}

    public DbBackup( String name, String path, Integer type, String operator, Date createTime, Integer state) {
        this.name = name;
        this.path = path;
        this.type = type;
        this.operator = operator;
        this.createTime = createTime;
        this.state = state;
    }



    public DbBackup(Integer id,String name,String path,Integer type,String operator,LocalDateTime createTime,Integer state) {
        this.id = id;
        this.name = name;
        this.path = path;
        this.type = type;
        this.operator = operator;
        ZoneId zone = ZoneId.systemDefault();
        ZonedDateTime zonedDateTime = createTime.atZone(zone);
        Instant instant = zonedDateTime.toInstant();
        this.createTime = Date.from(instant);
        this.state = state;
    }

//    public String getCreateTime() {
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        // Date date = new Date();
//        return simpleDateFormat.format(this.createTime);
//    }
//
//    public void setCreateTime(String createTime) {
//        try {
//            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//            this.createTime = simpleDateFormat.parse(createTime);
//        } catch (ParseException e) {
//            e.printStackTrace();
//            //
//        }
//    }
}
